<template>
  <div 
    class="collapse-btn"
    :class="{ collapsed: !modelValue }"
    @click="$emit('update:modelValue', !modelValue)"
  >
    <el-icon class="icon">
      <Fold v-if="modelValue" />
      <Expand v-else />
    </el-icon>
  </div>
</template>

<script setup lang="ts">
import { Fold, Expand } from '@element-plus/icons-vue'

defineProps<{
  modelValue: boolean
}>()

defineEmits<{
  (e: 'update:modelValue', value: boolean): void
}>()
</script>

<style scoped lang="scss">
.collapse-btn {
  position: absolute;
  right: -11px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background-color: var(--el-bg-color);
  border: 1px solid var(--el-border-color-light);
  border-radius: 0 4px 4px 0;
  transition: all $transition-duration;
  
  .icon {
    font-size: 16px;
    color: var(--el-text-color-secondary);
    transition: transform $transition-duration;
  }
  
  &:hover {
    background-color: var(--el-color-primary-light-9);
    
    .icon {
      color: var(--el-color-primary);
    }
  }
  
  &.collapsed {
    .icon {
      transform: rotate(180deg);
    }
  }
}

// 深色模式适配
html.dark {
  .collapse-btn {
    background-color: var(--el-bg-color);
    border-color: var(--el-border-color-light);
    
    &:hover {
      background-color: var(--el-color-primary-light-9);
    }
  }
}
</style> 